#pragma once
#include <string>
#include <vector>

using namespace std;

class FullArrange
{
public:
	void Init(string d[], int num, int size)
	{
		data.clear();
		flags.clear();
		result.clear();

		pathSize = size;
		for (int i = 0; i < num; i++)
		{
			data.push_back(d[i]);
		}
		flags.resize(data.size(), false);
		
		vector<string> begin;
		Arrange(begin);
	}

	vector<vector<string>> GetResult() { return result; }

private:
	void Arrange(vector<string> r)
	{
		if (r.size() >= pathSize)
		{
			result.push_back(r);
			return;
		}

		for (size_t i = 0; i < data.size(); i++)
		{
			if (flags[i])
			{
				continue;
			}
			r.push_back(data[i]);
			flags[i] = true;

			Arrange(r);

			r.pop_back();
			flags[i] = false;
		}
	}

private:
	size_t pathSize;
	vector<string> data;
	vector<bool> flags;
	vector<vector<string>> result;
};